#include<bits/stdc++.h>
using namespace std;
const int N=100002;
long long d[N],v[N],a[N],p[N];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    for(int z=0;z<t;z++){
        long long n,m,l,vv;
        cin>>n>>m>>l>>vv;
        bool special=1;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]<0)
                special=1;
        }
        for(int i=1;i<=m;i++)
            cin>>p[i];
        sort(p+1,p+m+1);
        int cnt=0;
        if(special){
            for(int i=1;i=n;i++){
                if(d[i]>p[m])
                    continue;
                bool chao=0;
                if(v[i]>vv)
                    chao=1;
                if(vv*vv-v[i]*v[i]<(p[m]-d[i])*2*a[i])
                    chao=1;
                if(chao==1)  cnt++;
            }
            cout<<cnt<<" ";
            if(cnt==0)  cout<<m<<endl;
            else  cout<<m-1<<endl;
        }
    }
    return 0;
}
